﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MyVideoManager.ItemsPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyVideoManager"
    xmlns:data="using:MyVideoManager.Data"
    xmlns:common="using:MyVideoManager.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- Collection d'éléments affichés par cette page -->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
    </Page.Resources>

    <!--
        La grille sert de panneau racine à la page, permettant de définir deux lignes :
        * La ligne 0 qui contient le bouton Précédent et le titre de la page
        * La ligne 1 qui contient le reste de la page
    -->
  <Page.BottomAppBar>
	  <AppBar x:Name="btmAppbar">
		<Button x:Name="addappbarButton" Click="FolderOpener" IsEnabled="true" Style="{StaticResource AddAppBarButtonStyle}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0" Canvas.ZIndex="-1"/>
	  </AppBar>
  </Page.BottomAppBar>
	
    <Grid x:Name="Page" Style="{StaticResource LayoutRootStyle}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:2"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled" />
                <VisualState x:Name="FullScreenPortrait" />
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DefaultView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid x:Name="DefaultView">
            <Grid Height="130" VerticalAlignment="Top">
            	<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="42,42,0,0" Canvas.ZIndex="-1"/>
            	<TextBlock x:Name="pageTitle" Text="My Video Manager" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Height="40" Width="479" Margin="139,42,0,0"/>
            </Grid>
            <GridView
                x:Name="itemGridView"
                AutomationProperties.AutomationId="ItemsGridView"
                AutomationProperties.Name="Items"
                TabIndex="1"
                Padding="50,0,50,50"
                ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
                ItemTemplate="{StaticResource Standard500x130ItemTemplate}"
                SelectionMode="None"
                IsSwipeEnabled="false"
                IsItemClickEnabled="True"
                ItemClick="ItemView_ItemClick" SelectionChanged="itemGridView_SelectionChanged" Margin="0,130,0,0" Grid.Column="1" Grid.Row="1" UseLayoutRounding="True"/>
        </Grid>
                <!-- Liste de défilement vertical utilisée uniquement lorsque l'état d'affichage a la valeur Snapped -->
        <Grid x:Name="SnappedView" Visibility="Collapsed">
            <ListView
                x:Name="itemListView"
                AutomationProperties.AutomationId="ItemsListView"
                AutomationProperties.Name="Items"
                TabIndex="1"
                Margin="0,5,0,0"
                Padding="10,0,0,60"
                ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
                ItemTemplate="{StaticResource Standard80ItemTemplate}"
                SelectionMode="None"
                IsSwipeEnabled="false"
                IsItemClickEnabled="True"
                ItemClick="ItemView_ItemClick" Grid.ColumnSpan="2" Grid.Row="1"/>
        </Grid>
    </Grid>
</common:LayoutAwarePage>
